package com.example.demo.controller;

import com.example.demo.model.UserInfo;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private UserService userService;
    @RequestMapping("/add")
    @Transactional
    public int add () {
        // 1.非空校验
        UserInfo userInfo = new UserInfo();
        userInfo.setUsername("zhangsan1111");
        userInfo.setPassword("123");
        // 2.调用service
        int result = userService.add(userInfo);
        System.out.println(result);
        int num = 10/0;
        return result;
        // 3.返回给前端
    }

}
